package cn.tedu.spring.iocxml.bean;

import cn.tedu.spring.iocxml.bean.Student;
import cn.tedu.spring.iocxml.bean.StudentImpl;
import cn.tedu.spring.iocxml.bean.StudentImpl2;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ruoLi
 */
public class TestStudent {
    //接口有一个唯一的实现类，能否根据接口class获取bean
    @Test
    public void impl(){
        ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");
        Student student1 = (Student) ctx.getBean("studentImpl1");
        student1.run();
        Student student2 = (Student) ctx.getBean(StudentImpl2.class);
        student2.run();
    }
}
